home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / PROG_TOO / C023A.ZIP / PART1 / STRNCAT.C < prev    next >
Text File  |  1990-01-31  |  459b  |  29 lines

  1. /*
  2.  *    STRING FUNCTIONS FOR SMALL C
  3.  *     BASED ON CORRESPONDING UNIX FUNCTIONS
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8.  
  9. /*
  10.  *  strncat - concatenate n bytes max from from to end of to
  11.  *            to must be long enough
  12.  */
  13. strncat( to, from, n )
  14. char *to, *from ;
  15. int n ;
  16. {
  17.     char *temp ;
  18.  
  19.     temp = to ;
  20.     --to ;
  21.     while( *++to ) ;
  22.     while( n-- ) {
  23.         if( *to++ = *from++ ) continue ;
  24.         return temp ;
  25.     }
  26.     *to = 0 ;
  27.     return temp ;
  28. }
  29.